import itertools

import gmpy2
import sympy

if __name__ == '__main__':
    i = 11
    res = set()
    faut = {'2', '4', '6', '8', '0', '5'}
    while i < 1000000:
        if len(set(list(str(i))).intersection(faut)) == 0:
            flag = 1
            for j in [(str(i) + str(i))[k:k + len(str(i))] for k in range(1, len(str(i)))]:
                print(j)
                if not gmpy2.is_prime(int(j)):
                    flag = 0
                    break
            if flag == 1:
                res.add(i)
        i = sympy.nextprime(i)
    print(len(res) + 4)
